import vuexHelper from '../libs/vuex-helper';
import menus from './menus.js';

let index = 0;
menus.forEach(m => {
  m.meta = m.meta || {
    activedMenu: 0,
    requireAuth: false
  };

  if (m.visible != false) {
    m.meta.activedMenu = index;

    index++;
  }
});

const extraState = {
  menus,
  area: {
    tableDetail: {
      height: 500
    }
  },
  selectedTable: {
    dbIndex: "",
    schema: "",
    tableName: ""
  },
  requestTypes: ['query', 'body', 'header']
};

export default vuexHelper.init(extraState, {
  changeTable (state, dbIndex, schema, tableName) {
    state.selectedTable.dbIndex = dbIndex;
    state.selectedTable.schema = schema;
    state.selectedTable.tableName = tableName;
  },
  changeTableDetailHeight (state, height) {
    state.area.tableDetail.height = height;
  }
}, {});